# Maintainer: Martell Malone <martellmalone@gmail.com>

pkgname=bzr
pkgver=2.7.0
pkgrel=2
pkgdesc="Bazaar is a version control system that helps you track project history over time and to collaborate easily with others."
arch=('i686' 'x86_64')
url="https://bazaar.canonical.com/en/"
license=('GPL')
groups=('VCS')
depends=('python2')
#optdepends=('python-paramiko: for sftp support')
source=("https://launchpad.net/${pkgname}/${pkgver%.*}/${pkgver}/+download/${pkgname}-${pkgver}.tar.gz"{,.sig}
        0001-setup.py-man-install.patch
        0002-add-msys2-certs-location.patch
        0003-bzr-lazy-regex.patch)
sha256sums=('0d451227b705a0dd21d8408353fe7e44d3a5069e6c4c26e5f146f1314b8fdab3'
            'SKIP'
            'f8b22c317e0b47b4cae024533b00ee3c682275963041b3cc7d8067ee6ca0cda3'
            '9fa03bd856a290b3d90eb83e6f5238aed3da475aec263e83a2da54197aa09f53'
            'b53c3dc8cba6f2c9758b61f0e9f40fc8452304e1fec15345e282dcd9d5657542')
validpgpkeys=('84736900600FF95EF23513F52975A150DEF6218F') # Vincent Ladeuil

prepare(){
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/0001-setup.py-man-install.patch
  patch -p1 -i ${srcdir}/0002-add-msys2-certs-location.patch
  # Arch Linux patch, https://github.com/Alexpux/MSYS2-packages/issues/826
  patch -p0 -i ${srcdir}/0003-bzr-lazy-regex.patch

  sed -e 's|/usr/bin/env python|/usr/bin/env python2|' \
      -i bzrlib/{plugins/bash_completion/bashcomp.py,tests/ssl_certs/create_ssls.py,patiencediff.py,_patiencediff_py.py}
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  python2 setup.py build
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  python2 setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1

  # bash-completion
  install -D -m644 contrib/bash/bzr "${pkgdir}/usr/share/bash-completion/completions/bzr"
}
